﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using ListenMusic.Message_ServiceReference;
namespace ListenMusic.Models.Reposistory.User
{
    public class MessageResposistory
    {
       
        public bool AddMessage(Message message)
        {
            try
            {
                MessageServiceClient clientMessage = new MessageServiceClient();
                clientMessage.ClientCredentials.UserName.UserName ="ClientUser";
                clientMessage.ClientCredentials.UserName.Password="123456";
                return clientMessage.AddMessage(message);
            }
            catch(FaultException ex)
            {
                throw ex;
            }

        }

        public bool AddMessageRecipient(MessageRecipient message)
        {
            try
            {
                MessageServiceClient clientMessage = new MessageServiceClient();
                clientMessage.ClientCredentials.UserName.UserName = "ClientUser";
                clientMessage.ClientCredentials.UserName.Password = "123456";
                return clientMessage.AddMessageRe(message);
            }
            catch (FaultException ex)
            {
                throw ex;
            }

        }

        public List<VW_Message> LoadMessageByUser(string username,string type)
        {
            try
            {
                MessageServiceClient clientMessage = new MessageServiceClient();
                clientMessage.ClientCredentials.UserName.UserName = "ClientUser";
                clientMessage.ClientCredentials.UserName.Password = "123456";
                VW_Message[] lst_mes = clientMessage.LoadMessageByUser(username,type);
                return lst_mes.ToList();
            }
            catch (FaultException ex)
            {
                throw ex;
            }
        }

    }
}